import { Injectable } from '@angular/core';
import { HttpService } from '../HTTP/http.service';
import { HttpParams } from '@angular/common/http';

import { usermanegeApirequestInterface } from './interface/usermanege.apirequest.interface';
@Injectable()
export class UserManageApirequest implements usermanegeApirequestInterface {
  constructor(private http: HttpService) {
  }

  /**
   * 注册用户
   * @param UserName 用户名
   * @param Password 密码
   * @param RoleId 角色
   */
  createUser(UserName: string, Password: string, RoleId: string): Promise<string> {
    return this.http.post('/api/user/manage/Create', { UserName, Password, RoleId });
  }
  
  /**
   * 更新用户资料
   * @param UserId 用户id
   * @param UserName 用户名
   * @param RoleId 角色
   */
  updateUser(UserId: string, UserName: string, RoleId: string): Promise<void> {
    return this.http.post('/api/user/manage/Update', { UserId, UserName, RoleId });
  }

  /**
   * 删除用户
   * @param UserId string
   */
  deleteUser(UserId: any): Promise<void> {
    return this.http.post('/api/user/manage/Delete', { UserId });
  }

  /**
   * 获取用户列表
   */
  getUserLs(): Promise<any> {
    return this.http.get('/api/user/manage/List');
  }

  /**
   * 更新密码
   * @param UserId 用户id
   * @param NewPassword 新密码 
   */
  reserUserPwd(UserId: string, NewPassword: string): Promise<void> {
    return this.http.post('/api/user/manage/ResetPassword', { UserId, NewPassword });
  }

  /**
   * 获取所有角色
   */
  getRoleLs(): Promise<any> {
    return this.http.get('/api/user/manage/Role/List');
  }

  /**
   * 根据id获取用户信息
   * @param userId 
   */
  getUserById(userId: string): Promise<any> {
    return this.http.get('/api/user/manage/FindById', { userId });
  }

}